﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using sharp_net.Repositories;
using sharp_net.Repositories.MongoDB;

namespace danreng.Domain {
    public class Shop : DomainMongo, IAggregateRoot {
        [Required]
        public string Name { get; set; }

        [Required]
        public string UrlRegular { get; set; }
        [Required]
        public string PriceGrab { get; set; }
        
        public string RebateTemp { get; set; } //生成折扣链接的模板
        
        public void Update(ShopData data) {
            base.Update((DomainMongoData)data);
            if (!string.IsNullOrEmpty(data.Name))
                this.Name = data.Name;
            if (!string.IsNullOrEmpty(data.UrlRegular))
                this.UrlRegular = data.UrlRegular;
            if (!string.IsNullOrEmpty(data.PriceGrab))
                this.PriceGrab = data.PriceGrab;
            if (!string.IsNullOrEmpty(data.RebateTemp))
                this.RebateTemp = data.RebateTemp;
        }
    }

    public class ShopData : DomainMongoData {
        public string Name { get; set; }
        public string UrlRegular { get; set; }
        public string PriceGrab { get; set; }
        public string RebateTemp { get; set; }
    }
}
